<template>
	<div class="qf-login orange-page" @keyup.13="login">
        <a href="#" id="loginLogo"></a>
        <div class="container">
            <div class="qf-login-broadcast fl">
                <div class="broadcast-txt">
                    <p>助力经纪人快速客户报备</p>
                    <p>实时了解最新成交与分佣情况</p>
                    <p>将提高经纪人工作效率</p>
                </div>
            </div>
            <div class="qf-login-form fl">
                <div class="qf-login-title">巧分销</div>
                <div class="login-form">
                    <div class="qf-input-box">
                        <div class="input-icon fl">
                            <div class="input-icon-img1"></div>
                        </div>
                        <div class="qf-input fl">
                            <input type="text" name="phone"v-model="loginData.phone" placeholder="请输入手机号">
                        </div>
                    </div>
                    <div class="qf-input-box">
                        <div class="input-icon fl">
                            <div class="input-icon-img2"></div>
                        </div>
                        <div class="qf-input fl">
                            <input type="password" name="password"v-model="loginData.password" placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="reset-password">
                        <a  href="javascript:void(0)" @click="toResetPwd" style="color:#666;text-decoration-line: underline;">忘记密码</a>
                    </div>
                </div>
                <a class="btn-login btn-login-orange" @click="login" style="margin-top:20px">登&nbsp;&nbsp;录</a>
                <div class="qf-login-footer" style="margin-top: 50px">上海巧房信息科技有限公司</div>
            </div>
        </div>
    </div>
</template>

<script>
	export default {
		data() {
				return {
					loginData:{
						 phone:'',
						 password:''
					},
					companyList:[]
				}
			},
			mounted: function() {
				this.initPage();
				this.getCompanyLogo();
				//this.loadCompany();
			},
			methods: {
				getCompanyLogo: function () {
	                var _self = this;
	                var url = _self.utilHelper.apiUrl + "/api/getLogo";
	                var params = {"params":{'logoType': '7'}}
	                _self.$http.post(url, params).then((response) => {
	                    var data = response.body;
	                    if (data.result=='1') {
	                        //_self.logoUrl = data.resData;
	                        $("#loginLogo").addClass("logo");
	                        $("#loginLogo").css("backgroundImage","url("+data.resData.logoUrl+")");
	                    }else{
	                    	$("#loginLogo").addClass("logo");
	                    }
	                })
	            },
				initPage() {
					// 设置高度
					var oMain = $(".sign-content");
					var oHeight = $(window).height();
					if(oHeight > 973) {
						oMain.css("height", "973px");
					} else if(oHeight < 800) {
						oMain.css("height", "800px");
					} else {
						oMain.css("height", oHeight + "px");
					}
				},
				login() {
					var _self=this;
					if(_self.vaild()){
						_self.loginData.domain = window.location.href;
	    		  		var params = {"params":_self.loginData};
	    		  		var url = _self.utilHelper.apiUrl + "/api/login";
				   	 	_self.$http.post(url, params).then((response) => {
								var data = response.body;
					   			var result=data.result;
					   			var errorMsg = data.resData.resultMsg;
			    		    	if(result=="1"){
				    		    		window.localStorage.setItem("4_userId", data.resData.id);
				    		    		window.localStorage.setItem("4_userName", data.resData.accountName);
										window.localStorage.setItem("4_isLogin", true);
										window.localStorage.setItem("4_accountType",data.resData.accountType);
										_self.$router.replace({
											path: '/app'
										})
			    		    	}else{
		    		    		  	layer.msg(errorMsg, {
										time: 1000
									});
			    		    	}
					  		}, (response) => {
					  	});
					}
				},
				vaild:function(){
					var _self = this;
//					if(!_self.loginData.cooCompanyId){
//						layer.msg("请选择合作商",{
//							time: 2000
//						});
//						return false;
//					}
					if(!_self.loginData.phone){
						layer.msg("请输入登录帐号",{
							time: 2000
						});
						return false;
					}
					if(!_self.loginData.password){
						layer.msg("请输入登录密码",{
							time: 2000
						});
						return false;
					}
					return true;
				},
				//获取合作商
				loadCompany(){
					var _self = this;
					var params = {};
					var url = _self.utilHelper.apiUrl + "/member/loadCompany.do";
				   	_self.$http.post(url, params).then((response) => {	
				   	 	var data = response.body;
				   	 	_self.companyList = data
				   	});
				},
                toResetPwd(){
				    this.$router.push({path:'/forgetPassword'});
                }
			}
	}
</script>
<style>
	#app{height: 100%;}
	.row-select{height: 40px;line-height: 40px;width: 170px;background-color: transparent;padding-left: 8px;border:none;}
    .reset-password{width:298px;height:22px;line-height:22px;margin:0 auto;text-align: right;}
    .reset-password a{color:#666}
</style>